package src.com.atguigu03.list;

import java.util.Objects;

/**
 * ClassName: PersonTest
 * Description:
 *
 * @Author liu
 * @Create 2024/11/22 23:05
 * @Version 1.0
 */
public class Person {
    String name;
    int year;

    public Person() {
    }

    public Person(String name, int year) {
        this.name = name;
        this.year = year;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", year=" + year +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        System.out.println("Person>>>>equals");
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return year == person.year && Objects.equals(name, person.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, year);
    }
}
